Various methods have conventionally been employed for lossless data compression.
For example, a method of combining a prediction error with variable-length encoding depending on the frequency of appearance, by utilizing predictive encoding is generally employed.
In an area where data does not change, a method of using run-length encoding is generally employed.
Patent Literature 1 discloses a technique with which, when encoding an image, predictive encoding and variable-length encoding are performed if a plurality of pieces of predetermined data do not coincide with the past record of the input data. If they coincide, the encoding mode shifts to a run-length encoding mode, and run-length encoding is carried out.
Patent Literature 1 also discloses that when decoding is to be performed, the encoding mode shifts to the run-length encoding mode if the plurality of pieces of predetermined data coincide with the record of the decoded data, so the encoded image can be decoded.